<div class="tableToolbar">
    <div class="coll-md-8" id="addInput">
        <div class="coll-md-1">
            <input type="text" class='search' placeholder="项目名称" ng-model="ctrlScope.itemsearch.itemname">
        </div>
        <div class="coll-md-15">
            <input type="text" class='search' placeholder="用户名/真实姓名" ng-model="ctrlScope.itemsearch.name">
        </div>

        <div class="coll-md-3 scalenone" id="searchdate" datahide>
            <div class="coll-md-5">
                <p class="input-group">
                    <input type="text" class="search" placeholder="开始时间" uib-datepicker-popup="yyyy-MM-dd"
                           ng-model="ctrlScope.itemsearch.beginDateTimex" is-open="popup1.opened"
                           datepicker-options="dateOptions"
                           ng-minlength="1"/>
                    <span class="input-group-btn">
							            <button type="button" class="small-icon btn btn-default" ng-click="open1()"><i
                                                class="glyphicon glyphicon-calendar"></i></button>
							          </span>
                </p>
            </div>
            <div class="coll-md-5">
                <p class="input-group inline">
                    <input type="text" class="search" placeholder="结束时间" uib-datepicker-popup="yyyy-MM-dd"
                           ng-model="ctrlScope.itemsearch.endDateTimex" is-open="popup2.opened"
                           datepicker-options="dateOptions"
                           ng-minlength="1"/>
                    <span class="input-group-btn">
							            <button type="button" class="small-icon btn btn-default" ng-click="open2()"><i
                                                class="glyphicon glyphicon-calendar"></i></button>
							          </span>
                </p>
            </div>
        </div>
        <div class="coll-md-1">
            <input type="button" class="small-icon search2-icon" value="搜索" ng-click="search()">
            <input type="button" class="small-icon search2" value="搜索">
            <input type="button" class="small-icon reset-icon" reset-icon value="重置" ng-click="reset()">
            <input type="button" class="small-icon reset" value="重置">

            <div class="dropdown-menu-right">
                <input type="button" class="small-icon more-icon" value="更多" title='更多搜索项' id="more-icon"
                       data-toggle="dropdown"
                       aria-haspopup="true" aria-expanded="false">
                <input type="button" class="small-icon more" value="更多">
                <ul class="dropdown-menu" style='margin-left:80px;' aria-labelledby="dropdownMenu2" more-search>
                    <li><a href="javascript:;">日期搜索</a></li>
                </ul>
            </div>
        </div>
    </div>
    <div class="coll-md-2">
        <!--<input type="button" class="bttn pos-left" ng-click="addOrderModal()" value="新建">-->
        <!--<button class="small-icon btn btn-default pos-right"  ng-click="download()">-->
        <!--<i class="fa fa-download"></i>-->
        <!--</button>-->
    </div>
</div>
<div style="width:100%;overflow-x: auto">
    <table ui-table="orderParams" bordercolor="#eee" cellspacing="0px" style="border-collapse:collapse;">
        <thead>
        <tr>
            <th style="text-align:left;padding:4px 4px 4px 12px;">id</th>
            <th style="text-align: left;padding:4px;">项目名称</th>
            <th style="text-align: left;padding:4px;">每份金额</th>
            <th style="text-align: left;padding:4px;">内容</th>
            <th style="text-align: left;padding:4px;">满标时间</th>
            <th style="text-align: left;padding:4px;">添加时间</th>
            <th style="text-align: left;padding:4px;">操作</th>
        </tr>
        </thead>
        <tbody>

        <tr ng-repeat="item in orderParams.$rows" style="text-align: left">
            <td style="text-align: left;padding:4px 4px 4px 12px">{{item.id}}</td>
            <td style="text-align: left;padding:4px;">{{item.packageName}}</td>
            <td style="text-align: left;padding:4px;">{{item.eachAmount}}</td>
            <td style="text-align: left;padding:4px;width:40%;text-overflow:ellipsis;overflow:hidden;">{{item.content}}</td>
            <td style="padding:4px;text-align: left">{{item.firstCheckTime | date:'yyyy-MM-dd HH:mm:ss'}}</td>
            <td style="padding:4px;text-align: left">{{item.addtime | date:'yyyy-MM-dd HH:mm:ss'}}</td>
            <td style="text-align: left;padding:4px 20px 4px 4px;">
                <a ng-click="modifyModal(item.id)">计划表</a>
            </td>
        </tr>
        </tbody>
    </table>
</div>
<modal title="计划表" visible="showPage">
    <form class="form-horizontal" role="form" name="myForm" novalidate>
        <div class="form-body">
            <div class="tab-content" style="margin-top:10px;">
                <table ui-table="orderParams1" cellspacing="0px" style="border-collapse:collapse;">
                    <thead>
                    <tr>
                        <th>包计划名</th>
                        <th>期数</th>
                        <th>金额</th>
                        <th>利率</th>
                        <th>周期</th>
                        <th>还款方式</th>
                        <th>状态</th>
                        <th>投满时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="item in orderParams1.$rows">
                        <td>{{item.packagePlanName}}</td>
                        <td>第{{item.periods}}期</td>
                        <td>{{item.amount}}</td>
                        <td>{{item.rate}}</td>
                        <td>{{item.cycle}}{{item.cycleUnit | cycleUnit}}
                        </td>
                        <td>
                            <span ng-if="item.repayMethod==1">一次性还款</span>
                            <span ng-if="item.repayMethod==2">等额本息</span>
                            <span ng-if="item.repayMethod==3">先息后本</span>
                        </td>
                        <td>
                            <span ng-if="item.status==1">等待发布</span>
                            <span ng-if="item.status==2">投资中</span>
                            <span ng-if="item.status==3">已满标</span>
                            <span ng-if="item.status==4">已匹配审核</span>
                        </td>
                        <td>{{item.fullTime}}</td>
                        <td>
                            <a ng-if="item.periods==1 && item.status==3" ng-click="reviewModal(item.id)">复审</a>
                            <a ng-if="item.periods!=1 && item.status==3" ng-click="matchingModal(item.id)">匹配</a>
                            <a ng-if="item.status==1" ng-click="releaseModal(item.id)">发布</a>
                            <a ng-click="repayBtn(item.id,2)" ng-if="item.status==4">借款人还款</a>
                            <a ng-click="repayBtn(item.id,1)" ng-if="item.status==4">标的还款</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </form>
</modal>
<modal title="匹配" visible="matchingPage">
    <form class="form-horizontal" role="form" name="myForm" ng-submit="submitForm(myForm.$valid)" novalidate>
        <div class="form-body">
            <ul id="myTab" class="nav nav-tabs">
                <li class="active"><a href="#item1" data-toggle="tab">匹配前</a></li>
                <li><a href="#item2" data-toggle="tab">匹配后</a></li>
            </ul>
            <div class="scrollArea">
                <div class="tab-content" style="margin-top:10px;">
                    <div class="tab-pane fade in active" id="item1">
                        <div class="form-group col-md-6">
                            <table cellspacing="0px" style="border-collapse:collapse;">
                                <div class="col-md-12" style="text-align:center;height:45px;line-height:45px">
                                    上期购买情况
                                </div>
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>购买人</th>
                                    <th>购买数量</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="item in planList">
                                    <td>{{item.id}}</td>
                                    <td>{{item.userId}}</td>
                                    <td>{{item.investDealAmount}}</td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="form-group col-md-6 floatR">
                            <table cellspacing="0px" style="border-collapse:collapse;">
                                <div class="col-md-12" style="text-align:center;height:45px;line-height:45px">
                                    本期购买情况
                                </div>
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>购买人</th>
                                    <th>购买数量</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="item in planList1">
                                    <td>{{item.id}}</td>
                                    <td>{{item.userId}}</td>
                                    <td>{{item.investDealAmount}}</td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="tab-pane fade" id="item2">
                        <div class="form-group">
                            <table cellspacing="0px" style="border-collapse:collapse;">
                                <div class="col-md-12" style="height:45px;">
                                    <div class="coll-md-6">
                                    </div>
                                    <div class="coll-md-2">
                                        <input type="button" class="bttn pos-left" ng-click="split()" value="拆分">
                                    </div>
                                    <div class="coll-md-2">
                                        <input type="button" class="bttn pos-left" ng-click="submitForm()" value="自动匹配">
                                    </div>
                                </div>
                                <thead>
                                <tr>
                                    <th></th>
                                    <th>上期购买人 - 购买数量</th>
                                    <th></th>
                                    <th>本期购买人 - 购买数量</th>
                                    <th style="width:150px;">匹配状态</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="item in planList4">
                                    <td></td>
                                    <td>{{item.beforeUserId}} － {{item.beforeNumber}}</td>
                                    <td></td>
                                    <td>{{item.userId}} － {{item.investDealAmount}}</td>
                                    <td></td>

                                </tr>
                                <tr ng-repeat="item in planList5">
                                    <td></td>
                                    <td style="width:300px;">
                                        <!--<select class="form-control" style="height: 34px !important;"-->
                                                <!--name="_before[$index]"-->
                                                <!--ng-change="beforeChange(item._before[$index],$index)"-->
                                                <!--ng-multiple="item.laterData[$index].length<=1 || !item.laterData"-->
                                                <!--ui-select2="select2Options" ng-model="item._before[$index]" required>-->
                                            <!--<option ng-if="item.laterData[$index].length>1" value="-1">请选择</option>-->
                                            <!--<option ng-repeat="item in planList2"-->
                                                    <!--ng-class="{1:'bgRed',0:''}[(item.status==-1 || item.status==undefined)?0:1]"-->
                                                    <!--value="{{$index}}">-->
                                                <!--{{item.userId}}－{{item.investDealAmount}}份-->
                                            <!--</option>-->
                                        <!--</select>-->
                                        <select class="form-control" style="height: 34px !important;"
                                                name="_before[$index]"
                                                multiple="multiple"
                                                ng-change="beforeChange(item._before[$index],$index)"
                                                ui-select2="select2Options" ng-model="item._before[$index]" required>
                                            <option ng-repeat="item in planList2"
                                                    ng-class="{1:'bgRed',0:''}[(item.status==-1 || item.status==undefined)?0:1]"
                                                    value="{{$index}}">
                                                {{item.userId}}－{{item.investDealAmount}}份
                                            </option>
                                        </select>
                                    </td>
                                    <td></td>
                                    <td style="width:300px;">
                                        <select class="form-control bgWhite" style="height: 34px !important; "
                                                name="_later[$index]"
                                                multiple="multiple"
                                                ng-change="laterChange(item._later[$index],$index)"
                                                ui-select2="select2Options" ng-model="item._later[$index]" required>
                                            <!--<option ng-if="item.beforeData[$index].length>1" value="-1">请选择</option>-->
                                            <option ng-repeat="item in planList3"
                                                    ng-class="{1:'bgRed',0:''}[(item.status==-1 || item.status==undefined)?0:1]"
                                                    value="{{$index}}">
                                                {{item.userId}}－{{item.investDealAmount}}份
                                            </option>
                                        </select>
                                    </td>
                                    <td>
                                        {{item.beforeTotal}}-{{item.laterTotal}}
                                        <i ng-class="{1:'fa fa-check colorGreen',0:' fa fa-times colorRed'}[(item.beforeTotal>0 && (item.beforeTotal==item.laterTotal))?1:0]"></i>
                                    </td>

                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-12 buttonArea">
                <button type="button" class="btn blue" ng-click="matchingAdd()">确定</button>
            </div>
        </div>
    </form>
</modal>
<modal title="拆分" visible="splitPage">
    <form class="form-horizontal" role="form" name="myForm" ng-submit="submitForm(myForm.$valid)" novalidate>
        <div class="form-body">
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label class="control-label col-md-4">上期购买人—数量：</label>
                        <div class="col-md-8">
                            <select class="form-control" style="height: 34px !important;" name="companyName"
                                    ui-select2="select2Options" ng-model="splitPack.companyName" required>
                                <option value="">请选择</option>
                                <option ng-repeat="item in planList2" ng-if="item.status ==-1 || item.status == undefined" value="{{$index}}">
                                    {{item.userId}}－{{item.investDealAmount}}份
                                </option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label class="control-label col-md-4">拆出份额：</label>
                        <div class="col-md-8">
                            <input type="number" min="0" class="form-control" ng-model="splitPack.investDealAmount">
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-12 buttonArea">
                <button type="button" class="btn blue" ng-click="splitAdd()">确定</button>
            </div>
        </div>
    </form>
</modal>
<modal title="复审" visible="reviewPage">
    <form class="form-horizontal" role="form" name="reviewForm" ng-submit="submitForm(reviewForm.$valid)" novalidate>
        <div class="form-body">
            <div class="row">

                <div class="col-md-2">
                    <div class="form-group">
                        <label class="control-label col-md-12">审核意见{{review.fullVerifyStatus}}</label>
                    </div>
                </div>
                <div class="col-md-10">
                    <div class="form-group">
                        <div class="col-md-8">
                            <label class="radio-inline">
                                <input type="radio"  name="review.fullVerifyStatus" value="1" ng-model="review.fullVerifyStatus" required>
                                同意 </label>
                            <label class="radio-inline">
                                <input type="radio" name="review.fullVerifyStatus" value="0" ng-model="review.fullVerifyStatus" required>
                                不同意 </label>
                        </div>

                    </div>
                </div>
            </div>
            <div class="col-md-12 buttonArea">
                <button type="button" class="btn blue" ng-disabled="reviewForm.$invalid" ng-click="reviewAdd(review.fullVerifyStatus)">确定</button>
            </div>
        </div>
    </form>
</modal>
<modal title="发布" visible="releasePage" style="margin:250px auto;">
    <form class="form-horizontal" role="form" id="form">
        <div class="form-body">
            <div class="row">
                <div class="col-md-12">
                    <label for="">
                        确定发布此项目吗?
                    </label>

                </div>
            </div>
            <div class="col-md-12 buttonArea">
                <button type="button"  class="btn blue" ng-click="releaseSubmit()">确定</button>
                <button type="button"  class="btn default" ng-click="cancel()" style="margin-left:10px;">取消</button>
            </div>
        </div>

    </form>
</modal>